<?php require VIEW_ROOT.'/common/header.php'?>

<div class="info">
	支出按数额分布
</div>

<table>
	<tr>
		<th width="120">条件</th>
		<th width="80">总额</th>
		<th width="80">占比</th>
		<th></th>
	</tr>
	<tr>
		<td>总额</td>
		<td>
			<?php
				$sum = $p->get_sum();
				$L300 = $p->get_sum(300);
				$L100 = $p->get_sum(100);
				$L50 = $p->get_sum(50);
				$L20 = $p->get_sum(20);
			?>
			<?php echo library_common::money_num($sum)?>
		</td>
		<td>
			100%
		</td>
		<td class="frm">
			<img src="./resource/images/liteui/th_bg.gif" width="500px" height="8" />
		</td>
	</tr>
	<tr>
		<td>300以上</td>
		<td>
			<?php echo library_common::money_num($sum - $L300)?>
		</td>
		<td>
			<?php echo $percent = round(100 - $L300 / $sum * 100, 1)?>%
		</td>
		<td class="frm">
			<img src="./resource/images/liteui/th_bg.gif" width="<?php echo $percent*5?>px" height="8" />
		</td>
	</tr>
	<tr>
		<td>100~300</td>
		<td>
			<?php echo library_common::money_num($L300 - $L100)?>
		</td>
		<td>
			<?php echo $percent = round(($L300 - $L100) / $sum * 100, 1)?>%
		</td>
		<td class="frm">
			<img src="./resource/images/liteui/th_bg.gif" width="<?php echo $percent*5?>px" height="8" />
		</td>
	</tr>
	<tr>
		<td>50~100</td>
		<td>
			<?php echo library_common::money_num($L100-$L50)?>
		</td>
		<td>
			<?php echo $percent = round(($L100 - $L50) / $sum * 100, 1)?>%
		</td>
		<td class="frm">
			<img src="./resource/images/liteui/th_bg.gif" width="<?php echo $percent*5?>px" height="8" />
		</td>
	</tr>
	<tr>
		<td>20~50</td>
		<td>
			<?php echo library_common::money_num($L50 - $L20)?>
		</td>
		<td>
			<?php echo $percent = round(($L50 - $L20) / $sum * 100, 1)?>%
		</td>
		<td class="frm">
			<img src="./resource/images/liteui/th_bg.gif" width="<?php echo $percent*5?>px" height="8" />
		</td>
	</tr>
	<tr>
		<td>0~20</td>
		<td>
			<?php echo library_common::money_num($L20)?>
		</td>
		<td>
			<?php echo $percent = round($L20 / $sum * 100, 1)?>%
		</td>
		<td class="frm">
			<img src="./resource/images/liteui/th_bg.gif" width="<?php echo $percent*5?>px" height="8" />
		</td>
	</tr>
</table>

<?php
// Standard inclusions   
include("resource/pchart/pData.class.php");
include("resource/pchart/pChart.class.php");

// Dataset definition 
$DataSet = new pData;
$DataSet->AddPoint(array($sum - $L300, $L300 - $L100, $L100 - $L50, $L50 - $L20, $L20),"Serie1");
$DataSet->AddPoint(array("300 more", "100~300", "50~100",'20~50', '0~20'),"Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");

// Initialise the graph
$Test = new pChart(330,200);
$Test->drawFilledRoundedRectangle(7,7,323,193,5,240,240,240);
$Test->drawRoundedRectangle(5,5,325,195,5,230,230,230);

// This will draw a shadow under the pie chart
$Test->drawFilledCircle(122,102,70,200,200,200);

// Draw the pie chart
$Test->setFontProperties("resource/fonts/tahoma.ttf",8);
$Test->drawBasicPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),120,100,70,PIE_PERCENTAGE,255,255,218);
$Test->drawPieLegend(230,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);

$img_filename = 'resource/chart/payout_per.png';
$Test->Render($img_filename);
echo '<table><tr><th>数额比例</th></tr> <tr><td style="background:#ffffff;text-align:left;"><img src="'.$img_filename.'"></td></tr></table>';
?>


<?php require VIEW_ROOT.'/common/footer.php'?>